Fix shape mismatch errors in MICE imputation
authorDebian Science Maintainers <debian-science-maintainers@lists.alioth.debian.org>
Sat, 2 Mar 2019 14:59:35 +0000 (14:59 +0000)
committerRebecca N. Palmer <rebecca_palmer@zoho.com>
Sat, 2 Mar 2019 14:59:35 +0000 (14:59 +0000)
numpy/pandas no longer allows assigning an nx1 2D value at a 1D index

Author: Peter "thequackdaddy" Quackenbush, Josef "josef-pkt" Perktold
Origin: upstream https://github.com/statsmodels/statsmodels/commit/df92bde1a85c238db9561304a196dbc618cfeaa1 https://github.com/statsmodels/statsmodels/commit/0871eba510e7ebe8aa9323f4f3ee50226576ed29
Forwarded: not-needed

Gbp-Pq: Name imputation_broadcasting.patch

statsmodels/imputation/mice.py

index a7778c4b7c201f7e462fbb87628342338926d914..233a7512371b963db35b1d77a9d2fb9432ecdb66 100644 (file)
@@ -392,7 +392,7 @@ class MICEData(object):
 
         ix = self.ix_miss[col]
         if len(ix) > 0:
-            self.data[col].iloc[ix] = vals
+            self.data[col].iloc[ix] = np.atleast_1d(vals)
 
 
     def update_all(self, n_iter=1):
@@ -1076,7 +1076,7 @@ class MICEData(object):
         ix = dxi[[jj, ir]]
         iz = ixm[[jj, ix]]
 
-        imputed_miss = np.array(endog_obs[iz])
+        imputed_miss = np.array(endog_obs[iz]).squeeze()
         self._store_changes(vname, imputed_miss)